package com.basic.system.controller;

import com.basic.common.result.WebResult;
import com.basic.system.domain.SystemFile;
import com.basic.system.domain.bo.SystemFileBo;
import com.basic.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/systemFile")
public class SysFileController {

    @Autowired
    private SystemService systemService;

    //添加新文件
    @PostMapping("/insert")
    public WebResult insert(@RequestBody SystemFile systemFile) {
        return WebResult.success(systemService.insert(systemFile));
    }

    //批量添加新文件
    @PostMapping("/insertById")
    public int insertById(@RequestBody List<SystemFile> systemFiles ){
        return systemService.insertById(systemFiles);
    }


    //根据业务ID字符串批量添加文件
    @PostMapping("/insertByRefStrId")
    public int insertByRefStrId(@RequestBody List<SystemFile> systemFiles ){
        String s ="444";
        return systemService.insertByRefStrId(systemFiles,s,"video");
    }

    //根据业务ID批量添加文件
    @PostMapping("/insertByRefId")
    public int insertByRefId(@RequestBody List<SystemFile> systemFiles ){
        Long s =444L;
        return systemService.insertByRefId(systemFiles,s);
    }

    //根据文件ID删除文件
    @RequestMapping(value = "/delById",method = RequestMethod.POST)
    public WebResult<Object> deleteById(@RequestBody SystemFile systemFile) {
        return WebResult.success(systemService.delByFileId(systemFile.getId()));
    }

    //根据业务ID删除文件
    @RequestMapping(value = "/deleteByRefId",method = RequestMethod.POST)
    public WebResult deleteByRefID(@RequestBody SystemFile systemFile) {
        return WebResult.success(systemService.deleteByRefId(systemFile));
    }

    //根据业务ID字符串删除文件
    @RequestMapping(value = "/deleteByRefStrId",method = RequestMethod.POST)
    public WebResult deleteByRefStrID(@RequestBody SystemFile systemFile) {
        return WebResult.success(systemService.deleteByRefStrId(systemFile));
    }


    //批量删除文件
    @RequestMapping(value = "/delete",method =RequestMethod.POST)
    public WebResult delete(@RequestBody SystemFileBo systemFileBo) {
        return WebResult.success( systemService.deleteByBo(systemFileBo));
    }

    //更新文件信息
    @PostMapping("/update")
    public WebResult updateFile(@RequestBody SystemFile systemFile) {

        return WebResult.success( systemService.updateFile(systemFile));
    }

    //不分页查询文件
    @PostMapping("/select")
    public WebResult select(@RequestBody SystemFile systemFile) {

        return WebResult.success(systemService.selectByBo(systemFile));
    }
    //分页查询
    @PostMapping("/selectByPage")
    public  WebResult pageList(@RequestBody SystemFileBo bo ){
        return WebResult.success(systemService.pageList(bo));

    }


}
